package com.appistry.maven.plugin.far;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

/**
 * Copies fabric resources (fabric application descriptor, component and task
 * descriptors) and scripts required by the application (fabric/far) to the work
 * directory
 * 
 * @goal copy-resources
 * @phase package
 * @requiresDependencyResolution runtime
 */
public class CopyResourcesMojo extends AbstractFarMojo {

	public void execute() throws MojoExecutionException, MojoFailureException {
		// if src/main/fabric-resources (or specified) directory does not exist,
		// then throw return
		if (!existsFabricResourcesSourceDirectory()) {
			return;
		}

		getLog().debug("In CopyResourcesMojo");

		copyResources();
	}

	private void copyResources() throws MojoExecutionException {
		getLog().debug("Copying resources");

		copyFabricResourceFiles(getFabricResourcesSourceDirectory(),
				getFabricAppDirectory());
	}

}
